#include <iostream>
#include <string>
#include <algorithm>
using namespace  std;
short dp[5010][5010];
string str1;
string str2;

int main()
{	
	int n;
	while(cin>>n)
	{
		cin >> str1;
		str2 = str1;
		int len = str1.size();
		reverse(str2.begin(), str2.end());
		memset(dp, 0, sizeof(dp));			
		for(int i=0;i<len;++i)
		{
			for(int j=0;j<len;++j)
			{
				if(str1[i]==str2[j])				
					dp[i + 1][j + 1] = dp[i][j] + 1;				
				else				
					dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);				
			}
		}
		cout << len - dp[len][len] << endl;		
	}
	return 0;	
}